package com.ruoyi.project.video.livetextcontent.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.video.livetextcontent.domain.Livetextcontent;
import com.ruoyi.project.video.livetextcontent.service.ILivetextcontentService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 图文直播内容Controller
 * 
 * @author ruoyi
 * @date 2024-11-25
 */
@Controller
@RequestMapping("/video/livetextcontent")
public class LivetextcontentController extends BaseController
{
    private String prefix = "video/livetextcontent";

    @Autowired
    private ILivetextcontentService livetextcontentService;

    @RequiresPermissions("video:livetextcontent:view")
    @GetMapping()
    public String livetextcontent()
    {
        return prefix + "/livetextcontent";
    }

    /**
     * 查询图文直播内容列表
     */
    @RequiresPermissions("video:livetextcontent:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Livetextcontent livetextcontent)
    {
        startPage();
        List<Livetextcontent> list = livetextcontentService.selectLivetextcontentList(livetextcontent);
        return getDataTable(list);
    }

    /**
     * 导出图文直播内容列表
     */
    @RequiresPermissions("video:livetextcontent:export")
    @Log(title = "图文直播内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Livetextcontent livetextcontent)
    {
        List<Livetextcontent> list = livetextcontentService.selectLivetextcontentList(livetextcontent);
        ExcelUtil<Livetextcontent> util = new ExcelUtil<Livetextcontent>(Livetextcontent.class);
        return util.exportExcel(list, "图文直播内容数据");
    }

    /**
     * 新增图文直播内容
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存图文直播内容
     */
    @RequiresPermissions("video:livetextcontent:add")
    @Log(title = "图文直播内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Livetextcontent livetextcontent)
    {
        return toAjax(livetextcontentService.insertLivetextcontent(livetextcontent));
    }

    /**
     * 修改图文直播内容
     */
    @RequiresPermissions("video:livetextcontent:edit")
    @GetMapping("/edit/{ContentID}")
    public String edit(@PathVariable("ContentID") Long ContentID, ModelMap mmap)
    {
        Livetextcontent livetextcontent = livetextcontentService.selectLivetextcontentByContentID(ContentID);
        mmap.put("livetextcontent", livetextcontent);
        return prefix + "/edit";
    }

    /**
     * 修改保存图文直播内容
     */
    @RequiresPermissions("video:livetextcontent:edit")
    @Log(title = "图文直播内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Livetextcontent livetextcontent)
    {
        return toAjax(livetextcontentService.updateLivetextcontent(livetextcontent));
    }

    /**
     * 删除图文直播内容
     */
    @RequiresPermissions("video:livetextcontent:remove")
    @Log(title = "图文直播内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(livetextcontentService.deleteLivetextcontentByContentIDs(ids));
    }
}
